***** SM1 *****
use "Parallel Trends Plot State Data.dta", clear

*** Figure 1: Testing the Parallel Trends Assumption ***
graph set window fontface "Times New Roman"

* Figure SM1 - Trends in Zilla Panchayat Turnout in Karnataka and Other States
twoway (connected Turnout Year if State == 1, mcolor(red) lcolor(red%90) xline(2010, lcolor(red)) lwidth(thick)) (connected avgmean Year if State == 2, mcolor(white%0) lcolor(black%90) lwidth(thick)), ytitle("Voter Turnout (%)", size(medlarge)) xtitle("Year", size(medlarge)) xlabel(2000 "2000" 2005 "2005" 2010 "2010" 2015 "2015" 2020 "2020") ylabel(50(10)100, gmin gmax) legend (order(1 "Karnataka" 2 "Control States (Average)") rows(2) size(medsmall)) graphregion(color(white)) plotregion(lcolor(black)) xsize(5) ysize(5) legend(size(small) position(6) region(lcolor(black)))

*** Table SM1 - Comparing Pre-Intervention Trends in Zilla Panchayat Turnout ***

reg interpolated_1 c.Year##i.Treated if Year < 2015

***** SM2 *****
use "Full Dataset Merged and Coded.dta", clear

*** Table SM2 - Covariate Balance Table ***
estpost ttest Turnout femalepoppct SCSTpoppct SecondEducpct CollegeEducpct avgdistage avgexpendperdist, by(Treated)

***** SM3 *****
graph set window fontface "Times New Roman" 
use "Full Dataset Merged and Coded.dta", clear

*** Figure SM2: Conditional Effects of Compulsory Voting ***
*District Age
sum   avgdistage, detail
global p25 = r(p25)
global p75 = r(p75)

reg Turnout i.Time##i.Treated##c.avgdistage if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   avgdistage = $p25) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   avgdistage_p25


reg Turnout i.Time##i.Treated##c.avgdistage if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   avgdistage = $p75) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   avgdistage_p75



coefplot ///
		( avgdistage_p25, offset(.3) recast(scatter) mcolor(red) msize(medium) ciopts(lpattern(solid) lcolor(red))) ///
		(  avgdistage_p75, offset(-.3) recast(scatter) mcolor(gs5) msize(medium) ciopts(lpattern(solid) lcolor(gs5))) ///
	,  scheme(s1color) horizontal ///
	xlabel(0(5)20, labsize(vsmall)) xscale(range(-1 21)) xtitle(" " " ", size(vsmall)) xscale(titlegap(2)) ///
	ylabel(	 .7 	`" "25th " "Percentile "  "'  ///
			 1.3	`" "75th " "Percentile "  "'  ///				 	
					) ///
	ylabel(, labsize(vsmall) )  legend(off) ///
	level(95) format(%9.0f) ysize(2) xsize(5) scale(3) ///
	graphregion(fcolor(white) lwidth(none) margin(vsmall)) ///
	xline(0,   lcolor(gs10) lwidth(thin) lpattern(solid)) ///
	xscale(range(-5 20)) ///
	plotregion(lalign(outside)) title(Average Age, size(small)) ///
	name(Age, replace)

*Average Expenditures
sum   avgexpendperdist, detail
global p25 = r(p25)
global p75 = r(p75)

reg Turnout i.Time##i.Treated##c.avgexpendperdist if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   avgexpendperdist = $p25) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   avgexpendperdist_p25


reg Turnout i.Time##i.Treated##c.avgexpendperdist if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   avgexpendperdist = $p75) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   avgexpendperdist_p75



coefplot ///
		( avgexpendperdist_p25, offset(.3) recast(scatter) mcolor(red) msize(medium) ciopts(lpattern(solid) lcolor(red))) ///
		(  avgexpendperdist_p75, offset(-.3) recast(scatter) mcolor(gs5) msize(medium) ciopts(lpattern(solid) lcolor(gs5))) ///
	,  scheme(s1color) horizontal ///
	xlabel(0(5)20, labsize(vsmall)) xscale(range(-1 21)) xtitle(" " " ", size(vsmall)) xscale(titlegap(2)) ///
	ylabel(	 .7 	`" "25th " "Percentile "  "'  ///
			 1.3	`" "75th " "Percentile "  "'  ///				 	
					) ///
	ylabel(, labsize(vsmall) )  legend(off) ///
	level(95) format(%9.0f) ysize(2) xsize(5) scale(3) ///
	graphregion(fcolor(white) lwidth(none) margin(vsmall)) ///
	xline(0,   lcolor(gs10) lwidth(thin) lpattern(solid)) ///
	xscale(range(-5 20)) ///
	plotregion(lalign(outside)) title(Average Expenditures, size(small)) ///
	name(Expend, replace)

*Secondary Education Percent
sum  SecondEducpct, detail
global p25 = r(p25)
global p75 = r(p75)

reg Turnout i.Time##i.Treated##c.SecondEducpct if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)  SecondEducpct = $p25) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store  SecondEducpct_p25


reg Turnout i.Time##i.Treated##c.SecondEducpct if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)  SecondEducpct = $p75) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store  SecondEducpct_p75



coefplot ///
		(SecondEducpct_p25, offset(.3) recast(scatter) mcolor(red) msize(medium) ciopts(lpattern(solid) lcolor(red))) ///
		( SecondEducpct_p75, offset(-.3) recast(scatter) mcolor(gs5) msize(medium) ciopts(lpattern(solid) lcolor(gs5))) ///
	,  scheme(s1color) horizontal ///
	xlabel(0(5)20, labsize(vsmall)) xscale(range(-1 21)) xtitle(" " " ", size(vsmall)) xscale(titlegap(2)) ///
	ylabel(	 .7 	`" "25th " "Percentile "  "'  ///
			 1.3	`" "75th " "Percentile "  "'  ///				 	
					) ///
	ylabel(, labsize(vsmall) )  legend(off) ///
	level(95) format(%9.0f) ysize(2) xsize(5) scale(3) ///
	graphregion(fcolor(white) lwidth(none) margin(vsmall)) ///
	xline(0,   lcolor(gs10) lwidth(thin) lpattern(solid)) ///
	xscale(range(-5 20)) ///
	plotregion(lalign(outside)) title(% Secondary Education, size(small)) ///
	name(Secondary, replace)


*College Educated Percent
sum   CollegeEducpct, detail
global p25 = r(p25)
global p75 = r(p75)

reg Turnout i.Time##i.Treated##c.CollegeEducpct if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   CollegeEducpct = $p25) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   CollegeEducpct_p25


reg Turnout i.Time##i.Treated##c.CollegeEducpct if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   CollegeEducpct = $p75) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   CollegeEducpct_p75



coefplot ///
		( CollegeEducpct_p25, offset(.3) recast(scatter) mcolor(red) msize(medium) ciopts(lpattern(solid) lcolor(red))) ///
		(  CollegeEducpct_p75, offset(-.3) recast(scatter) mcolor(gs5) msize(medium) ciopts(lpattern(solid) lcolor(gs5))) ///
	,  scheme(s1color) horizontal ///
	xlabel(0(5)20, labsize(vsmall)) xscale(range(-1 21)) xtitle(" " " ", size(vsmall)) xscale(titlegap(2)) ///
	ylabel(	 .7 	`" "25th " "Percentile "  "'  ///
			 1.3	`" "75th " "Percentile "  "'  ///				 	
					) ///
	ylabel(, labsize(vsmall) )  legend(off) ///
	level(95) format(%9.0f) ysize(2) xsize(5) scale(3) ///
	graphregion(fcolor(white) lwidth(none) margin(vsmall)) ///
	xline(0,   lcolor(gs10) lwidth(thin) lpattern(solid)) ///
	xscale(range(-5 20)) ///
	plotregion(lalign(outside)) title(% College Educated, size(small)) ///
	name(College, replace)

*Female Population Pct
sum   femalepoppct, detail
global p25 = r(p25)
global p75 = r(p75)

reg Turnout i.Time##i.Treated##c.femalepoppct if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   femalepoppct = $p25) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   femalepoppct_p25


reg Turnout i.Time##i.Treated##c.femalepoppct if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   femalepoppct = $p75) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   femalepoppct_p75



coefplot ///
		( femalepoppct_p25, offset(.3) recast(scatter) mcolor(red) msize(medium) ciopts(lpattern(solid) lcolor(red))) ///
		(  femalepoppct_p75, offset(-.3) recast(scatter) mcolor(gs5) msize(medium) ciopts(lpattern(solid) lcolor(gs5))) ///
	,  scheme(s1color) horizontal ///
	xlabel(0(5)20, labsize(vsmall)) xscale(range(-1 21)) xtitle("Impact of Compulsory Voting" "on Turnout Rate", size(small)) xscale(titlegap(2))  ///
	ylabel(	 .7 	`" "25th " "Percentile "  "'  ///
			 1.3	`" "75th " "Percentile "  "'  ///				 	
					) ///
	ylabel(, labsize(vsmall) )  legend(off) ///
	level(95) format(%9.0f) ysize(2) xsize(5) scale(3) ///
	graphregion(fcolor(white) lwidth(none) margin(vsmall)) ///
	xline(0,   lcolor(gs10) lwidth(thin) lpattern(solid)) ///
	xscale(range(-5 20)) ///
	plotregion(lalign(outside)) title(% Female Population, size(small)) ///
	name(female, replace)
	
* SCST Population
sum   SCSTpoppct, detail
global p25 = r(p25)
global p75 = r(p75)

reg Turnout i.Time##i.Treated##c.SCSTpoppct if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   SCSTpoppct = $p25) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   SCSTpoppct_p25


reg Turnout i.Time##i.Treated##c.SCSTpoppct if Year == 2010 | Year == 2015 | Year == 2013 | Year == 2018 | Year == 2011 | Year == 2019, vce (cluster District)
margins, dydx(Time) at(Treated = (0 1)   SCSTpoppct = $p75) coefleg post
lincomest _b[1.Time:2._at]-_b[1.Time:1bn._at]
est store   SCSTpoppct_p75



coefplot ///
		( SCSTpoppct_p25, offset(.3) recast(scatter) mcolor(red) msize(medium) ciopts(lpattern(solid) lcolor(red))) ///
		(  SCSTpoppct_p75, offset(-.3) recast(scatter) mcolor(gs5) msize(medium) ciopts(lpattern(solid) lcolor(gs5))) ///
	,  scheme(s1color) horizontal ///
	xlabel(0(5)20, labsize(vsmall)) xscale(range(-1 21)) xtitle("Impact of Compulsory Voting" "on Turnout Rate", size(small)) xscale(titlegap(2)) ///
	ylabel(	 .7 	`" "25th " "Percentile "  "'  ///
			 1.3	`" "75th " "Percentile "  "'  ///				 	
					) ///
	ylabel(, labsize(vsmall) )  legend(off) ///
	level(95) format(%9.0f) ysize(2) xsize(5) scale(3) ///
	graphregion(fcolor(white) lwidth(none) margin(vsmall)) ///
	xline(0,   lcolor(gs10) lwidth(thin) lpattern(solid)) ///
	xscale(range(-5 20)) ///
	plotregion(lalign(outside)) title(% Scheduled Caste/Tribe, size(small)) ///
	name(SCST, replace)
	
graph combine Age Expend Secondary College female SCST, col(2) iscale(0.25) ysize(6) xsize(7) 

reg Turnout i.Time##i.Treated##c.  avgdistage
margins, dydx(Time) at(Treated = (0 1)   avgdistage = ($p25 $p75)) coefleg post
lincomest (_b[1.Time:2._at]-_b[1.Time:1bn._at]) - (_b[1.Time:4._at]-_b[1.Time:3._at])

***** SM6 *****
use "Full Dataset Merged and Coded.dta", clear

*** Table SM3: Results of Difference-in-Differences Models, NOTA Treatment ***
* Column 1 - Baseline Model
reg Turnout Time Treated_Rajasthan DID_Rajasthan if Year == 2010 | Year == 2011 | ///
Year == 2013 | Year == 2015 | Year == 2018 | Year == 2019, vce (cluster District)

* Column 2 - Covariate Model
reg Turnout Time Treated_Rajasthan DID_Rajasthan femalepoppct SCSTpoppct SecondEducpct CollegeEducpct ///
avgdistage avgexpendperdist if Year == 2010 | Year == 2011 | Year == 2013 | Year == 2015 | ///
 Year == 2018 | Year == 2019, vce (cluster District)

* Column 3 - State Fixed Effects Model: 
reg Turnout Time Treated_Rajasthan DID_Rajasthan femalepoppct SCSTpoppct SecondEducpct ///
CollegeEducpct avgdistage avgexpendperdist i.State i.Year ///
if Year == 2010 | Year == 2011 | Year == 2013 | Year == 2015 | Year == 2018 | ///
Year == 2019, vce (cluster District)

***** SM7 *****
use "Karnataka Election Data ALL.dta", clear

*** Figure SM4: Turnout Trends in Other Karnatakan Elections ***
twoway (connected Turnout Year if Election == 4, mcolor(red) lcolor(red%90) lwidth(thick) xline(2010, lcolor(red) lpattern(dash))) (connected Turnout Year if Election == 3, mcolor(black) lcolor(black%90) lwidth(thick) xline(2013, lcolor(black) lpattern(dash))) (connected Turnout Year if Election == 2, mcolor(blue) lcolor(blue%90) lwidth(thick) xline(2014, lcolor(blue) lpattern(dash))), ytitle("Voter Turnout (%)", size(medlarge)) xtitle("Year", size(medlarge)) xlabel(2000 "2000" 2005 "2005" 2010 "2010" 2015 "2015" 2020 "2020" 2025 "2025") ylabel(50(10)100, gmin gmax) legend (order(1 "Panchayat" "Elections" 2 "Karnataka Legislative" "Assembly Elections" 3 "Indian General" "Elections") rows(2) size(medsmall)) graphregion(color(white)) plotregion(lcolor(black)) xsize(5) ysize(5) legend(size(small) position(6) region(lcolor(black))) 

***** SM8 *****
use "Full Dataset Merged and Coded.dta", clear

*** Table SM4 - Summary Statistics ***
summarize Turnout femalepoppct SecondEducpct CollegeEducpct avgdistage SCSTpoppct ///
avgexpendperdist